<layout name="page" />
<block name="content">
	{:widget('page_header/simple',array('name'=>'修改项目'))}
	<div class="frame">
		<form method='post' id="form_data" name="form_data" enctype="multipart/form-data"  >
			<input type="hidden" name="id" id="id" value="{$vo.id}">
			<input type="hidden" name="pid" id="pid" value="{$vo.project_id}">
			<input type="hidden" id="ajax" name="ajax" value="1">
			<input type="hidden" id="member" name="member" value="">
			<input type="hidden" id="opmode" name="opmode" value="edit">
			<div class="box col-12">
				<label class="input-label" for="name">标题*：</label>
				<input class="input" type="text" id="name" name="name" value="{$vo.name}" check="required" info="请输入标题">
			</div>
			<div class="box col-12">
				<label class="input-label" for="name">日期*：</label>
				<input type="text" class="input input-date" name="start_date" id="start_date" readonly="readonly" value="{$vo.start_date}" check="required" info="请选择开始日期">
				<i class="date-mid">-</i>
				<input type="text" class="input input-date" name="end_date" id="end_date" readonly="readonly" value="{$vo.end_date}" check="required" info="请选择结束日期">
			</div>
			<div class="box col-12">
				<label class="input-label" >项目成员：</label>
				<div id="member_list" class="multi-select-box">
					<span class="data-list">{:show_contact($vo['member'],'edit')}</span>
					<input class="letter" type="text" >
					<label></label>
					<div class="search hidden">
						<ul></ul>
					</div>
				</div>
				<a class="add-on" onclick="select_member();"><i class="fa fa-user"></i></a>
			</div>
			<foreach name="field_list" val="udf_vo">
				{:widget('user_define_field/edit',array($udf_vo))}
			</foreach>
			<div class="box col-12">
				<label class="input-label" >项目描述：</label>
				<textarea  class="input simple" style="height:200px;" id="content" name="content">{$vo.content}</textarea>
			</div>
			<div class="box col-12">
				<label class="input-label" >附件：</label>
				{:widget('file_upload/edit',array('add_file'=>$vo['add_file']))}
			</div>
			<div class="box col-12">
				<label class="input-label" ></label>
				<a class="btn btn-normal" onclick="save()">保存</a>
				<a class="btn btn-return" onclick="go_return_url();">取消</a>
			</div>
		</form>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		layui.use(['global', 'editor'], function() {
			var $ = layui.jquery;
			var fn = {
				select_member : function() {
					winopen("{:url('select_member')}", 560, 470);
				},
				save : function() {
					var member = [];
					$("#member_list span.data-list a").each(function() {
						$this = $(this);
						name = $this.text();
						data = $this.attr('data');
						member.push({
							name : name,
							data : data
						});
					});
					$("#member").val(JSON.stringify(member));

					if ($("#member_list span.data-list a").length == 0) {
						layer.msg('请选择项目成员');
						return false;
					}
					send_form("form_data", "{:url('save')}", "{:url('index')}", function(ret) {
						if (ret.status) {
							layer.msg(ret.info, {
								time : 1200
							}, function() {
								location.href = "{:url('index')}";
							});
						} else {
							layer.msg(ret.info);
							return false;
						}
					});
				}
			};
			win_exp(fn);
		});
	</script>
</block>